<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="crm.model.Customer"%>
<%@page import="crm.util.ParamUtil"%>
<%@page import="crm.util.ToPinyin"%>
<%@page import="crm.model.Employees"%>
<%@page import="crm.control.CustomerControl"%>
<%@page import="crm.model.Linkman"%>
<%@page import="crm.control.LinkmanControl"%>

<%
           Customer c= new Customer();
      
         Employees cu = (Employees)session.getAttribute("user");
         
          int count = Integer.parseInt(request.getParameter("count"));
          System.out.print(count);
          c.setAddress(request.getParameter("address"));
          System.out.print(request.getParameter("business"));
           c.setArea_id(Integer.parseInt(request.getParameter("area_id")));
           System.out.print(c.getArea_id()+"EEEE");
           c.setBusiness(request.getParameter("business"));
           c.setCrete_time(request.getParameter("creat_time"));
           c.setName(request.getParameter("name"));
           c.setNamepy(ToPinyin.getPinYin(c.getName())); 
           System.out.print("EEEE"+c.getNamepy());
           c.setOrigin(request.getParameter("origin"));
           c.setPhone(request.getParameter("phone"));
           c.setEmployee_id(cu.getId());
           c.setType(request.getParameter("type"));
           
           int  addId =CustomerControl.addCustomer(c);
           int flag=0;
           if(addId>0){
               if(count%2==1){
			        	   Linkman l = new Linkman();
			        	   l.setBirthday(ParamUtil.getString(request,"l_birthday","1990-01-01"));
			        	   l.setCustomer_id(addId);
			        	   l.setEmail(ParamUtil.getString(request,"l_email","未填写"));
			        	   l.setGender(ParamUtil.getString(request,"l_gender","1"));
			        	   l.setHobby(ParamUtil.getString(request,"l_hobby","未填写"));
			        	   l.setName(ParamUtil.getString(request,"l_name","未填写"));
			        	   l.setPhone(ParamUtil.getString(request,"l_phone","未填写"));
			        	   l.setPosition(ParamUtil.getString(request,"l_pposition","无"));
			        	   l.setProvince(ParamUtil.getInt(request,"l_province_id",1));
			        	   l.setQq(ParamUtil.getString(request,"l_qq","0"));
			        	   if(LinkmanControl.addLinkman(l)){
			        		   flag=1;
			        	   }else{
			        		   flag=2;
			        	   }
               }else{
            	   flag=3;
               }
           }
          
          // boolean isSuccess = false;
           String returnJson = "{\"status\":\"" + flag + "\"}";
%>
 <%=returnJson %>